//
//  LineView.m
//  tabbar
//
//  Created by KWSD on 16/5/13.
//  Copyright © 2016年 孙添凤. All rights reserved.
//

#import "LineView.h"
#import "UIColor+CL.h"
#define SINGLE_LINE_WIDTH           (1 / [UIScreen mainScreen].scale)
#define SINGLE_LINE_ADJUST_OFFSET   ((1 / [UIScreen mainScreen].scale) / 2)
#define KWIDTH   ([UIScreen mainScreen].bounds.size.width)
@implementation LineView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor blackColor];
        
    }
    
    return self;
}



// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    
    UIView *v =[[UIView alloc]init];
    [self addSubview:v];
    v.backgroundColor =[UIColor colorWithHex:0xf5f5f5];
    float width = 33;
    
    if(KWIDTH>375){
        width = 38;
    }
    v.frame = CGRectMake(0, 0, width, 33*26);
    
    UIView *lineC = [[UIView alloc]init];
    [v addSubview:lineC];
    lineC.frame = CGRectMake(width-1, 0, 1, 33*26);
    lineC.backgroundColor =[UIColor colorWithHex:0xE6E6E6];
    
    for(int i=0;i<9;i++){
        
        float width = (KWIDTH-25)/7;
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetLineCap(context, kCGLineCapRound);
        CGContextSetLineWidth(context, 0);  //线宽
        CGContextSetAllowsAntialiasing(context, true);
        CGContextSetRGBStrokeColor(context, 230.0 / 255.0, 230.0 / 255.0, 230.0 / 255.0, 1.0);  //线的颜色
        CGContextBeginPath(context);
        
        CGContextMoveToPoint(context, width*i-20, 0);  //起点坐标
        CGContextAddLineToPoint(context, width*i-20, self.frame.size.height+300);   //终点坐标
        
        CGContextStrokePath(context);
    }
    
    for(int j=0;j<26;j++){
        
        
        float height = 33;
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetLineCap(context, kCGLineCapRound);
        CGContextSetLineWidth(context, 1);  //线宽
        CGContextSetAllowsAntialiasing(context, true);
        CGContextSetRGBStrokeColor(context, 230.0 / 255.0, 230.0 / 255.0, 230.0 / 255.0, 1.0);  //线的颜色
        CGContextBeginPath(context);
        
        CGContextMoveToPoint(context, 0, height*j+1);  //起点坐标
        CGContextAddLineToPoint(context, KWIDTH, height*j);   //终点坐标
        
        CGContextStrokePath(context);
        UILabel *timeLa = [[UILabel alloc]init];
        if(KWIDTH>375){
            timeLa.frame =CGRectMake(-3, height*j-17, KWIDTH/7-25, 45);
            [self addSubview:timeLa];
        }else if(KWIDTH<375){
            
            timeLa.frame =CGRectMake(7, height*j-15, KWIDTH/7-25, 45);
            [self addSubview:timeLa];
            
        }else{
            
            
            timeLa.frame =CGRectMake(3, height*j-15, KWIDTH/7-25, 45);
            [self addSubview:timeLa];
        }
        
        
        //        timeLa.backgroundColor =[UIColor redColor];
        timeLa.text = [NSString stringWithFormat:@"%d:%d0",j/2+8,(j%2)*3];
        if(KWIDTH<375){
            timeLa.font =[UIFont systemFontOfSize:7];
        }else{
            timeLa.font =[UIFont systemFontOfSize:10];
        }
        timeLa.textAlignment = NSTextAlignmentRight;
        
    }
    
}

@end
